import request from '@/utils/request';
import {UserDTO, UserQueryDTO} from "@/types/user";
import {stringify} from "querystring";

export async function queryListByCurrentOrganization(params:UserQueryDTO): Promise<any> {
  return request(`/user/query_list_by_current_organization`,{
    method: 'POST',
    data: params,
  });
}

export async function createByCurrentOrganization(params:UserDTO): Promise<any> {
  return request(`/user/create_by_current_organization`,{
    method: 'POST',
    data: params,
  });
}

export async function modifyByCurrentOrganization(params:UserDTO): Promise<any> {
  return request(`/user/modify_by_current_organization`,{
    method: 'PUT',
    data: params,
  });
}

export async function deleteByCurrentOrganization(params:{id:number}): Promise<any> {
  return request(`/user/delete_by_current_organization?${stringify(params)}`,{
    method: 'DELETE',
    data: params
  });
}


export async function queryList(params:UserQueryDTO): Promise<any> {
  return request(`/user/query_list`,{
    method: 'POST',
    data: params,
  });
}

export async function create(params:UserDTO): Promise<any> {
  return request('/user/create',{
    method: 'POST',
    data: params
  });
}

export async function modify(params:UserDTO): Promise<any> {
  return request('/user/modify',{
    method: 'PUT',
    data: params
  });
}

export async function _delete(params:{id:number}): Promise<any> {
  return request(`/user/delete?${stringify(params)}`,{
    method: 'DELETE',
    data: params
  });
}

export default {
  queryListByCurrentOrganization,
  createByCurrentOrganization,
  modifyByCurrentOrganization,
  deleteByCurrentOrganization,
  queryList,
  create,
  modify,
  _delete,
}
